import Vue from 'vue'
import router from 'vue-router'
import { Message } from "element-ui";
import 'element-ui/lib/theme-chalk/index.css'

//注册全局组件
Vue.use(router)
Vue.use(Message);

let a = null
export default a = new router({
    routes: [
        {
            path: '/',
            name: 'Show',
            component: () => import('@/components/Show.vue'),
            children: [
                 //往来账户-应收款-回显
                 {
                    path: '/yingshouhuixian',
                    name: 'yingshouhuixian',
                    component: () => import('@/components/currentMoney/yingshouhuixian'),
                },
                //往来账户-付款明细
                {
                    path: '/fukuan',
                    name: 'fukuan',
                    component: () => import('@/components/currentMoney/fukuan'),
                },
                 //往来账户-收款明细
                 {
                    path: '/shoukuan',
                    name: 'shoukuan',
                    component: () => import('@/components/currentMoney/shoukuan'),
                },
                //往来账户-预付款
                {
                    path: '/yufu',
                    name: 'yufu',
                    component: () => import('@/components/currentMoney/yufu'),
                },
                  //往来账户-预收款
                  {
                    path: '/yushou',
                    name: 'yushou',
                    component: () => import('@/components/currentMoney/yushou'),
                },
                 //往来账户-应付款
                 {
                    path: '/yingfu',
                    name: 'yingfu',
                    component: () => import('@/components/currentMoney/yingfu'),
                },
                    //往来账户-应收款
                    {
                        path: '/yingshou',
                        name: 'yingshou',
                        component: () => import('@/components/currentMoney/yingshou'),
                    },
                //账户汇总
                {
                    path: '/summary',
                    name: 'summary',
                    component: () => import('@/components/Moneymanage/Summary'),
                },
                //资金账户
                {
                    path: '/accounts',
                    name: 'accounts',
                    component: () => import('@/components/Moneymanage/accounts'),
                },
                   //资金流水
                   {
                    path: '/flow',
                    name: 'flow',
                    component: () => import('@/components/Moneymanage/flow'),
                },
                //收支科目
                {
                    path: '/subjects',
                    name: 'subjects',
                    component: () => import('@/components/Moneymanage/subjects'),
                },
                //测试
                {
                    path: '/Test',
                    name: 'test',
                    component: () => import('@/components/test'),
                },
                //人事工作台
                {
                    path: '/Personneldesk',
                    name: 'Personneldesk',
                    component: () => import('@/components/workbench/Personneldesk'),
                },
                 //公告管理
                 {
                    path: '/notice',
                    name: 'notice',
                    component: () => import('@/components/notice/notice'),
                },
                 //信息公告
                 {
                    path: '/informationNotice',
                    name: 'informationNotice',
                    component: () => import('@/components/notice/informationNotice'),
                },
                //文档管理
                {
                    path: '/document',
                    name: 'document',
                    component: () => import('@/components/document/document'),
                },
                  //文档分类
                {
                    path: '/documentclass',
                    name: 'documentclass',
                    component: () => import('@/components/document/documentclass'),
                },
                //员工假期
                {
                    path: '/holiday',
                    name: 'holiday',
                    component: () => import('@/components/holiday/Type'),
                },
                //请假记录表
                {
                    path: '/balance',
                    name: 'Balance',
                    component: () => import('@/components/holiday/Balance'),
                },
                //员工假期余额表
                {
                    path: '/leavedetail',
                    name: 'leavedetail',
                    component: () => import('@/components/holiday/LeaveDetail'),
                },
                //新建假期类型
                {
                    path: '/updatetype',
                    name: 'UpdateType',
                    component: () => import('@/components/holiday/updateType'),
                },
                //修改员工假期余额表
                {
                    path: '/updateBalance',
                    name: 'updateBalance',
                    component: () => import('@/components/holiday/updateBalance'),
                },

                //发起申请
                {
                    path: '/LaunchApplication',
                    name: 'LaunchApplication',
                    component: () => import('@/components/approver/LaunchApplication.vue'),
                },
                //审批中心 待处理  
                {
                    path: '/Pending',
                    name: 'Pending',
                    component: () => import('@/components/approver/Pending.vue'),
                },
                //审批中心 已处理 
                {
                    path: '/Processed',
                    name: 'Processed',
                    component: () => import('@/components/approver/Processed.vue'),
                },
                //我收到的
                {
                    path: '/Ireceived',
                    name: 'Ireceived',
                    component: () => import('@/components/approver/Ireceived.vue'),
                },
                //审批中心 我发起的 
                {
                    path: '/Iinitiated',
                    name: 'Iinitiated',
                    component: () => import('@/components/approver/Iinitiated.vue'),
                },
                //审批中心，请假 
                {
                    path: '/Leave',
                    name: 'Leave',
                    component: () => import('@/components/approver/Leave.vue'),
                },
                //审批中心，出差 
                {
                    path: '/Evection',
                    name: 'Evection',
                    component: () => import('@/components/approver/Evection.vue'),
                },
                //审批中心，加班
                {
                    path: '/Overtime',
                    name: 'Overtime',
                    component: () => import('@/components/approver/Overtime.vue'),
                },
                //审批中心，外出
                {
                    path: '/GoOut',
                    name: 'GoOut',
                    component: () => import('@/components/approver/GoOut.vue'),
                },
                //审批中心，详情页
                {
                    path: '/Particulars',
                    name: 'Particulars',
                    component: () => import('@/components/approver/Particulars.vue'),
                },
                //财务工作台
                {
                    path: '/Financialworkbench',
                    name: 'Financialworkbench',
                    component: () => import('@/components/workbench/Financialworkbench')
                },
                // 行政工作台
                {
                    path: '/Administrativeworkbench',
                    name: 'Administrativeworkbench',
                    component: () => import('@/components/workbench/Administrativeworkbench')

                },
                // 总经理工作台 
                {
                    path: '/GeneralManagerworkbench',
                    name: 'GeneralManagerworkbench',
                    component: () => import('@/components/workbench/GeneralManagerworkbench')

                },
                // 薪资
                {
                    path: '/SalaryCalculate',
                    name: 'SalaryCalculate',
                    component: () => import('@/components/salary/SalaryCalculate')

                },
                //添加薪资方案
                {
                    path: '/AddSalaryCalculate',
                    name: 'AddSalaryCalculate',
                    component: () => import('@/components/salary/AddSalaryCalculate')

                },
                 //薪资项目
                 {
                    path: '/PayrollItems',
                    name: 'PayrollItems',
                    component: () => import('@/components/salary/PayrollItems')

                },
                 //工资条
                 {
                    path: '/PaySlips',
                    name: 'PaySlips',
                    component: () => import('@/components/salary/PaySlips')

                },
                 //工资发放
                 {
                    path: '/Payroll',
                    name: 'Payroll',
                    component: () => import('@/components/salary/Payroll')

                },
                   //员工薪资档案
                   {
                    path: '/EmployeePayrollFiles',
                    name: 'EmployeePayrollFiles',
                    component: () => import('@/components/salary/EmployeePayrollFiles')

                },
                //操作日志
                {
                    path: '/operationlog',
                    name: 'operationlog',
                    component: () => import('@/components/setting/operationlog')
                },
                // 角色管理
                {
                    path: '/rolemanagement',
                    name: 'rolemanagement',
                    component: () => import('@/components/setting/rolemanagement')
                },
                // 角色管理 新增角色
                {
                    path: '/AddAndUpRole',
                    name: 'AddAndUpRole',
                    component: () => import('@/components/setting/addanduprole')
                },
                //消息通知
                {
                    path: '/messagenotification',
                    name: 'messagenotification',
                    component: () => import('@/components/setting/messagenotification')
                },
                {
                  path: '/Attendance',
                  name: 'Attendance',
                  component:() => import('@/components/attendance/attendanceIndex.vue')
                  
                },
                // 补卡
                {
                    path: '/ReplacementCardIndex',
                    name: 'replacementCardIndex',
                    component:() => import('@/components/attendance/replacementCard/replacementCardIndex.vue')
                    
                },
                // 新增补卡规则
                {
                    path: '/ReplacementCardAdd',
                    name: 'replacementCardAdd',
                    component:() => import('@/components/attendance/replacementCard/replacementCardAdd.vue')
                    
                },
                //  地图测试
                {
                    path:"/Demo",
                    name:"demo",
                    component: () => import('@/components/attendance/replacementCard/demo.vue')  
                },
                //  加班规则
                {
                    path: "/OvertimeIndex",
                    name: "overtimeIndex",
                    component: () => import('@/components/attendance/overtime/OvertimeIndex.vue')
                },
                //  新建加班规则
                {
                    path: "/OvertimeAdd",
                    name: "overtimeAdd",
                    component: () => import('@/components/attendance/overtime/OvertimeAdd.vue')
                },
                // 班次管理首页
                {
                    path: "/ShiftIndex",
                    name: "shiftIndex",
                    component: () => import('@/components/attendance/shift/ShiftIndex.vue')
                },
                // 班次新增/修改
                {
                    path: "/ShiftAdd",
                    name: "shiftAdd",
                    component: () => import('@/components/attendance/shift/ShiftAdd.vue')
                },
                // 考勤组首页
                {
                    path: "/ExaminationGroupIndex",
                    name: "ExaminationGroupIndex",
                    component: () => import('@/components/attendance/examinationGroup/ExaminationGroupIndex.vue')
                },
                // 考勤组新增
                {
                    path: "/ExaminationGroupAdd",
                    name: "ExaminationGroupAdd",
                    component: () => import('@/components/attendance/examinationGroup/ExaminationGroupAdd.vue')
                },
                //候选人
                {
                    path: '/Candidate',
                    name: 'Candidate',
                    component: () => import('@/components/recruit/Candidate')
                }
                //人才库
                , {
                    path: '/TalentPool',
                    name: 'TalentPool',
                    component: () => import('@/components/recruit/TalentPool')
                }
                //招聘管理 设置
                , {
                    path: '/Setting',
                    name: 'Setting',
                    component: () => import('@/components/recruit/Setting')
                }
                //简历数据
                , {
                    path: '/ResumeData',
                    name: 'ResumeData',
                    component: () => import('@/components/recruit/ResumeData')
                }
                //招聘概况
                , {
                    path: '/RecruitmentOverview',
                    name: 'RecruitmentOverview',
                    component: () => import('@/components/recruit/RecruitmentOverview')
                }
                //招聘漏斗
                , {
                    path: '/Recruitingfunnel',
                    name: 'Recruitingfunnel',
                    component: () => import('@/components/recruit/Recruitingfunnel')
                }
                //职位管理
                , {
                    path: '/PositionManagement',
                    name: 'PositionManagement',
                    component: () => import('@/components/recruit/PositionManagement')
                },
                //印章库
                {
                    path: '/Sealvault',
                    name: 'Sealvault',
                    component: () => import('@/components/seal/Sealvault')
                },
                //用章管理
                {
                    path: '/Managementbyseal',
                    name: 'Managementbyseal',
                    component: () => import('@/components/seal/Managementbyseal')
                },
                //资产列表
                {
                    path: '/PropertyList',
                    name: 'PropertyList',
                    component: () => import('@/components/property/PropertyList')
                },
                //添加资产
                {
                    path: '/AddProperty',
                    name: 'AddProperty',
                    component: () => import('@/components/property/AddProperty')
                },
                //公告管理
                {
                    path: '/notice',
                    name: 'notice',
                    component: () => import('@/components/notice/notice'),
                },
                 //信息公告
                 {
                    path: '/informationNotice',
                    name: 'informationNotice',
                    component: () => import('@/components/notice/informationNotice'),
                },
                 //信息公告详情页
                 {
                    path: '/xiangqing2',
                    name: 'xiangqing2',
                    component: () => import('@/components/notice/xiangqing2'),
                },
                //公告标题详情页
                {
                    path: '/xiangqing1',
                    name: 'xiangqing1',
                    component: () => import('@/components/notice/xiangqing1'),
                },
                 //公告标题详情页
                 {
                    path: '/addnotice',
                    name: 'addnotice',
                    component: () => import('@/components/notice/addnotice'),
                },
                //文档管理
                {
                    path: '/document',
                    name: 'document',
                    component: () => import('@/components/document/document'),
                },
                  //文档分类
                {
                    path: '/documentclass',
                    name: 'documentclass',
                    component: () => import('@/components/document/documentclass'),
                },
                 //添加文档
                {
                    path: '/addDocument',
                    name: 'addDocument',
                    component: () => import('@/components/document/addDocument'),
                },
                 //文档标题详情页
                 {
                    path: '/xiangqing',
                    name: 'xiangqing',
                    component: () => import('@/components/document/xiangqing'),
                },
                //内部通讯录
                {
                    path: '/InternalAddressBook',
                    name: 'InternalAddressBook',
                    component: () => import('@/components/addressbook/InternalAddressBook'),
                },
                //外部通讯录
                {
                    path: '/externalAddressBook',
                    name: 'externalAddressBook',
                    component: () => import('@/components/addressbook/externalAddressBook'),
                },
                  //详情外部通讯录
                  {
                    path: '/xiangqing4',
                    name: 'xiangqing4',
                    component: () => import('@/components/addressbook/xiangqing4'),
                },
                // 车辆管理
                {
                    path: '/vehiclemanagement',
                    name: 'vehiclemanagement',
                    component: () => import('@/components/car/vehiclemanagement/vehiclemanagement'),
                },
                // 添加车辆
                {
                    path: '/vehicleoperation',
                    name: 'vehicleoperation',
                    component: () => import('@/components/car/vehiclemanagement/vehicleoperation'),
                },
                // 用车管理generalvehiclemanagement
                {
                    path: '/generalvehiclemanagement',
                    name: 'generalvehiclemanagement',
                    component: () => import('@/components/car/vehiclemanagement/generalvehiclemanagement'),
                },
                //用车申请 generalvehicleoperation
                {
                    path: '/generalvehiclemanagement/generalvehicleoperation',
                    name: 'generalvehicleoperation',
                    component: () => import('@/components/car/vehiclemanagement/generalvehicleoperation'),
                },
                //用车申请 详情页
                {
                    path: '/generalvehiclemanagement/CarParticulars',
                    name: 'CarParticulars',
                    component: () => import('@/components/car/vehiclemanagement/Particulars.vue'),
                },
                //油卡管理 fuelcard
                {
                    path: '/fuelcard',
                    name: 'fuelcard',
                    component: () => import('@/components/car/vehicleservicemanagement/fuelcard.vue'),
                },
                //添加油卡充值记录 release addconsume
                {
                    path: '/addrelease',
                    name: 'addrelease',
                    component: () => import('@/components/car/add/addrelease.vue'),
                },
                //添加油卡消费记录
                {
                    path: '/addconsume',
                    name: 'addconsume',
                    component: () => import('@/components/car/add/addconsume.vue'),
                },
                //加油管理 cheer
                {
                    path: '/cheer',
                    name: 'cheer',
                    component: () => import('@/components/car/vehicleservicemanagement/cheer.vue'),
                },
                //添加加油管理 addcheer
                {
                    path: '/addcheer',
                    name: 'addcheer',
                    component: () => import('@/components/car/add/addcheer.vue'),
                },
                //保养管理 maintain
                {
                    path: '/maintain',
                    name: 'maintain',
                    component: () => import('@/components/car/maintain/maintain.vue'),
                },
                //添加保养记录 addmaintain
                {
                    path: '/addmaintain',
                    name: 'addmaintain',
                    component: () => import('@/components/car/maintain/addmaintain.vue'),
                },
                //维修管理 maintainer
                {
                    path: '/maintainer',
                    name: 'maintainer',
                    component: () => import('@/components/car/maintainer/maintainer.vue'),
                },
                //添加维修记录 addmaintainer
                {
                    path: '/addmaintainer',
                    name: 'addmaintainer',
                    component: () => import('@/components/car/maintainer/addmaintainer.vue'),
                },
                //保险管理 insurance
                {
                    path: '/insurance',
                    name: 'insurance',
                    component: () => import('@/components/car/insurance/insurance.vue'),
                },
                //添加维修记录 addmaintainer
                {
                    path: '/addinsurance',
                    name: 'addinsurance',
                    component: () => import('@/components/car/insurance/addinsurance.vue'),
                },
                //年检管理 inspect
                {
                    path: '/inspect',
                    name: 'inspect',
                    component: () => import('@/components/car/inspect/inspect.vue'),
                },
                //添加年检记录 addinspect
                {
                    path: '/addinspect',
                    name: 'addinspect',
                    component: () => import('@/components/car/inspect/addinspect.vue'),
                },
                //违章管理 illegal
                {
                    path: '/illegal',
                    name: 'illegal',
                    component: () => import('@/components/car/illegal/illegal.vue'),
                },
                //添加违章记录 addillegal
                {
                    path: '/addillegal',
                    name: 'addillegal',
                    component: () => import('@/components/car/illegal/addillegal.vue'),
                },
                //购车管理 purchase
                {
                    path: '/purchase',
                    name: 'purchase',
                    component: () => import('@/components/car/purchase/purchase.vue'),
                },
                //添加购车记录 addpurchase
                {
                    path: '/addpurchase',
                    name: 'addpurchase',
                    component: () => import('@/components/car/purchase/addpurchase.vue'),
                },
                //etc管理 etc
                {
                    path: '/etc',
                    name: 'etc',
                    component: () => import('@/components/car/etc/etc.vue'),
                },
                //添加etc 消费记录
                {
                    path: '/addetcconsume',
                    name: 'addetcconsume',
                    component: () => import('@/components/car/etc/addetcconsume.vue'),
                },
                // 档案 全宗设置 generalarchive
                {
                    path: '/generalarchive',
                    name: 'generalarchive',
                    component: () => import('@/components/record/global setting/generalarchive.vue'),
                },
                // 档案 库案管理 caselocker
                {
                    path: '/caselocker',
                    name: 'caselocker',
                    component: () => import('@/components/record/global setting/caselocker.vue'),
                },
                // 档案 添加库案管理 addcaselocker secrecy
                {
                    path: '/addcaselocker',
                    name: 'addcaselocker',
                    component: () => import('@/components/record/global setting/addcaselocker.vue'),
                },
                // 档案 保密管理 secrecy
                {
                    path: '/secrecy',
                    name: 'secrecy',
                    component: () => import('@/components/record/global setting/secrecy.vue'),
                },
                // 档案 案卷管理 archives
                {
                    path: '/archives',
                    name: 'archives',
                    component: () => import('@/components/record/global setting/archives.vue'),
                },
                // 档案 案卷管理 addarchives
                {
                    path: '/addarchives',
                    name: 'addarchives',
                    component: () => import('@/components/record/global setting/addarchives.vue'),
                },
                // 档案 案卷管理 filing
                {
                    path: '/filing',
                    name: 'filing',
                    component: () => import('@/components/record/record/filing.vue'),
                },
                //新建档案
                {
                    path: '/AddFiles',
                    name: 'AddFiles',
                    component: () => import('@/components/record/AddFiles')
                },
                //报销管理
                {
                    path: '/ReimbursementList',
                    name: 'ReimbursementList',
                    component: () => import('@/components/reimbursement/ReimbursementList')  
                },
                // 添加报销申请
                {
                    path: '/AddReimbursement',
                    name: 'AddReimbursement',
                    component: () => import('@/components/reimbursement/AddReimbursement')  
                },
                // 报销借款页面详情页
                {
                    path: '/ReimbursementById',
                    name: 'ReimbursementById',
                    component: () => import('@/components/reimbursement/ReimbursementById')  
                },
                // 借款管理
                {
                    path: '/BorrowMoneyList',
                    name: 'BorrowMoneyList',
                    component: () => import('@/components/reimbursement/BorrowMoneyList')  
                },
                // 借款添加
                {
                    path: '/AddBorrowMoney',
                    name: 'AddBorrowMoney',
                    component: () => import('@/components/reimbursement/AddBorrowMoney')  
                },
                //添加职位
                {
                    path: '/AddPositionManagement',
                    name: 'AddPositionManagement',
                    component: () => import('@/components/recruit/AddPositionManagement')
                },
                {
                    path: '/FindSalaryCalculateById',
                    name: 'FindSalaryCalculateById',
                    component: () => import('@/components/salary/FindSalaryCalculateById')
                },
                //前往发放
                {
                    path: '/Lssue',
                    name: 'Lssue',
                    component: () => import('@/components/salary/Lssue')
                },
                //候选人添加
                {
                    path: '/AddCandidate',
                    name: 'AddCandidate',
                    component: () => import('@/components/recruit/AddCandidate')
                },
            ]
        },
        {
            path: '/login',
            name: 'login',
            component: () => import('@/components/Login.vue'),
        },
        {
            path: '/register',
            name: 'register',
            component: () => import('@/components/Register.vue'),
        }
    ],
    mode: "history"

})

// 为路由对象添加路由导航守卫
a.beforeEach((to, from, next) => {
    if (to.path === '/login' || to.path === '/register') {  //  如果用户访问的是登录页面 直接放行
        return next();
    }

    let token = window.localStorage.getItem('token');  //  从LocalStorage中得到token
    const tokenStartTime = window.localStorage.getItem('tokenStartTime');  //   获取存储token的开始时间

    const timeOver = 1 * 3600 * 1000;  // 定义1个小时过期，让用户重新登录一下
    let date = new Date().getTime();  //  当前时间
    if (date - tokenStartTime > timeOver) {  //  如果大于说明是token过期了
        token = null;
        window.localStorage.removeItem("token");
        window.localStorage.removeItem("tokenStartTime");
    }

    // 如果没有token值 那么就跳转到'/login
    if (!token) {
        if (to.path == '/login') {
            return next();
        }
        Message({
            message: '登录失效，请重新登录',
            type: 'warning'
        });
        return next('/login');
    }

    // 如果有token则放行
    next();
})



